Skip to contentSkip to conversation

Change in openvpn[master]: Remove comparing username to NULL in tls_lock_username

Openvpn-devel In review plaisthos (Code Review) 3 participants 7 messages Jan 20, 2025 – Jan 27, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1737375148000.Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/871?usp=email

to review the following change.

Change subject: Remove comparing username to NULL in tls_lock_username
......................................................................

Remove comparing username to NULL in tls_lock_username

tls_lock_username is only called in a single place and that place calls this is function with up->username, which is always defined.

Change-Id Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20

---
M src/openvpn/ssl_verify.c

1 file changed, 3 insertions(+), 6 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/71/871/1

src/openvpn/ssl_verify.c +3 -6
index 4c4b58d..e7d7ed6 100644
@@ -153,11 +153,11 @@
 {
     if (multi->locked_username)
     {
-        if (!username || strcmp(username, multi->locked_username))
+        if (strcmp(username, multi->locked_username) != 0)
         {
             msg(D_TLS_ERRORS, "TLS Auth Error: username attempted to change from '%s' to '%s' -- tunnel disabled",
                 multi->locked_username,
-                np(username));
+                username);
 
             /* disable the tunnel */
             tls_deauthenticate(multi);
@@ -166,10 +166,7 @@
     }
     else
     {
-        if (username)
-        {
-            multi->locked_username = string_alloc(username, NULL);
-        }
+        multi->locked_username = string_alloc(username, NULL);
     }
     return true;
 }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/871?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20
Gerrit-Change-Number: 871
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/871?usp=email )

Change subject: Remove comparing username to NULL in tls_lock_username
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/871?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20
Gerrit-Change-Number: 871
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Tue, 21 Jan 2025 15:56:36 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 Remove comparing username to NULL in tls_lock_username

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

tls_lock_username is only called in a single place and that place calls this is function with up->username, which is always defined.

Change-Id Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/871
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

src/openvpn/ssl_verify.c +3 -6
index 4c4b58d..e7d7ed6 100644
@@ -153,11 +153,11 @@
 {
     if (multi->locked_username)
     {
-        if (!username || strcmp(username, multi->locked_username))
+        if (strcmp(username, multi->locked_username) != 0)
         {
             msg(D_TLS_ERRORS, "TLS Auth Error: username attempted to change from '%s' to '%s' -- tunnel disabled",
                 multi->locked_username,
-                np(username));
+                username);
 
             /* disable the tunnel */
             tls_deauthenticate(multi);
@@ -166,10 +166,7 @@
     }
     else
     {
-        if (username)
-        {
-            multi->locked_username = string_alloc(username, NULL);
-        }
+        multi->locked_username = string_alloc(username, NULL);
     }
     return true;
 }
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Remove comparing username to NULL in tls_lock_username

JFTR, v2 in gerrit is "the same as v1, just rebased", so taking what is already on the list here.

And indeed, in the only call chain to this, we have

    string_mod_remap_name(up->username);

.. so this should better be non-NULL :-) (ASSERT(str) in string_mod()).

Your patch has been applied to the master branch.

commit d9af13e8c222cba41000202908663a6d1e2cd028

Author: Arne Schwabe
Date:   Tue Jan 21 17:12:47 2025 +0100
     Remove comparing username to NULL in tls_lock_username

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg30520.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/871?usp=email

to look at the new patch set (#2).

The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied now.

Change subject: Remove comparing username to NULL in tls_lock_username
......................................................................

Remove comparing username to NULL in tls_lock_username

tls_lock_username is only called in a single place and that place calls this is function with up->username, which is always defined.

Change-Id Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20

---
M src/openvpn/ssl_verify.c

1 file changed, 3 insertions(+), 6 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/71/871/2

src/openvpn/ssl_verify.c +3 -6
index 4c4b58d..e7d7ed6 100644
@@ -153,11 +153,11 @@
 {
     if (multi->locked_username)
     {
-        if (!username || strcmp(username, multi->locked_username))
+        if (strcmp(username, multi->locked_username) != 0)
         {
             msg(D_TLS_ERRORS, "TLS Auth Error: username attempted to change from '%s' to '%s' -- tunnel disabled",
                 multi->locked_username,
-                np(username));
+                username);
 
             /* disable the tunnel */
             tls_deauthenticate(multi);
@@ -166,10 +166,7 @@
     }
     else
     {
-        if (username)
-        {
-            multi->locked_username = string_alloc(username, NULL);
-        }
+        multi->locked_username = string_alloc(username, NULL);
     }
     return true;
 }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/871?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20
Gerrit-Change-Number: 871
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/871?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

Change subject: Remove comparing username to NULL in tls_lock_username
......................................................................

Remove comparing username to NULL in tls_lock_username

tls_lock_username is only called in a single place and that place calls this is function with up->username, which is always defined.

Change-Id Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30520.html

---
M src/openvpn/ssl_verify.c

1 file changed, 3 insertions(+), 6 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/71/871/3

src/openvpn/ssl_verify.c +3 -6
index 4c4b58d..e7d7ed6 100644
@@ -153,11 +153,11 @@
 {
     if (multi->locked_username)
     {
-        if (!username || strcmp(username, multi->locked_username))
+        if (strcmp(username, multi->locked_username) != 0)
         {
             msg(D_TLS_ERRORS, "TLS Auth Error: username attempted to change from '%s' to '%s' -- tunnel disabled",
                 multi->locked_username,
-                np(username));
+                username);
 
             /* disable the tunnel */
             tls_deauthenticate(multi);
@@ -166,10 +166,7 @@
     }
     else
     {
-        if (username)
-        {
-            multi->locked_username = string_alloc(username, NULL);
-        }
+        multi->locked_username = string_alloc(username, NULL);
     }
     return true;
 }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/871?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20
Gerrit-Change-Number: 871
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#7 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/871?usp=email )

Change subject: Remove comparing username to NULL in tls_lock_username
......................................................................

Remove comparing username to NULL in tls_lock_username

tls_lock_username is only called in a single place and that place calls this is function with up->username, which is always defined.

Change-Id Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30520.html

---
M src/openvpn/ssl_verify.c

1 file changed, 3 insertions(+), 6 deletions(-)
src/openvpn/ssl_verify.c +3 -6
index 4c4b58d..e7d7ed6 100644
@@ -153,11 +153,11 @@
 {
     if (multi->locked_username)
     {
-        if (!username || strcmp(username, multi->locked_username))
+        if (strcmp(username, multi->locked_username) != 0)
         {
             msg(D_TLS_ERRORS, "TLS Auth Error: username attempted to change from '%s' to '%s' -- tunnel disabled",
                 multi->locked_username,
-                np(username));
+                username);
 
             /* disable the tunnel */
             tls_deauthenticate(multi);
@@ -166,10 +166,7 @@
     }
     else
     {
-        if (username)
-        {
-            multi->locked_username = string_alloc(username, NULL);
-        }
+        multi->locked_username = string_alloc(username, NULL);
     }
     return true;
 }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/871?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20
Gerrit-Change-Number: 871
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged